package com.lz.c;

import java.util.Scanner;

/**
 * @ClassName Demo28
 * @Description 打印全三角形
 * @Author 2214361854
 * @Date 2022/5/27 14:46
 * @Version 1.0
 */
public class Demo28 {
    /**
     * 实例：
     *      *
     *     ***
     *    *****
     *   *******
     *  *********
     *
     */
    public static void main(String[] args) {
        System.out.println("请输入您要打印星星的行数：");
        int hs = new Scanner(System.in).nextInt();
        CongruentTriangle(hs);
    }

    private static void CongruentTriangle(int hs) {
        //行数：[1,n],一共n行
        for (int i = 1; i <= hs; i++) {
            //空格个数：[0,n-i)
            for (int z = 0; z < hs - i; z++) {
                System.out.print(" ");
            }
            //星个数：[1,2*i-1]
            for (int k = 1; k <= 2 * i - 1; k++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}
